package cn.wp.ewallet.exchange.web.controller;

import cn.wp.common.core.Wp;
import cn.wp.common.core.dto.WpResult;
import cn.wp.common.core.web.WpUserContext;
import cn.wp.ewallet.common.service.PubItemDictService;
import cn.wp.ewallet.wallet.model.entity.UserCollectDo;
import cn.wp.ewallet.wallet.service.UserCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(Wp.WebContext + "/ewallet/collect")
@Api(tags = "A-用户收款账户")
public class UserCollectController {
    @Autowired
    private UserCollectService userCollectService;

    @GetMapping("/get")
    @ApiOperation(value = "获取用户个人账户",notes = "",tags = "")
    public WpResult get(){
        List<UserCollectDo> select = userCollectService.select("user_id = '" + WpUserContext.get().getId()+"'");
        return WpResult.suc(select);
    }
    @PostMapping("/add")
    @ApiOperation(value = "新增收款方式",notes = "",tags = "")
    public WpResult add(@ApiParam(required = true) UserCollectDo userCollect){
        userCollect.setUserId(WpUserContext.get().getId());
        userCollectService.insert(userCollect);
        return WpResult.suc();
    }
    @PostMapping("/upd")
    @ApiOperation(value = "修改收款方式",notes = "",tags = "")
    public WpResult upd(@ApiParam(required = true) UserCollectDo userCollect){
        userCollectService.updateByPrimaryKey(userCollect);
        return WpResult.suc();
    }
    @PostMapping("/del")
    @ApiOperation(value = "删除收款方式",notes = "",tags = "")
    public WpResult upd(@ApiParam(required = true,name = "collectId") @RequestParam String collectId){
        userCollectService.delete(collectId);
        return WpResult.suc();
    }

}
